package com.ptswitch.material.util;

import org.hxzon.tapestry5.model.ValueLabel;

import com.ptswitch.material.model.common.EMailAddress;
import com.ptswitch.material.model.common.Uzer;
import com.ptswitch.material.model.contract.ContractAttachment;
import com.ptswitch.material.model.material.Material;
import com.ptswitch.material.model.security.Permission;
import com.ptswitch.material.model.security.Role;

public class ValueLabelUtil {

    public static final ValueLabel<Permission> permissionLabel = new ValueLabel<Permission>() {
        public String toLabel(Permission p, int index) {
            return p.getDisplayName();
        }
    };

    public static final ValueLabel<Role> roleLabel = new ValueLabel<Role>() {
        public String toLabel(Role r, int index) {
            return r.getDisplayName();
        }
    };

    public static final ValueLabel<Uzer> uzerLabel = new ValueLabel<Uzer>() {
        public String toLabel(Uzer value, int index) {
            return value.getRealname();
        }
    };

    public static final ValueLabel<Uzer> uzerEmailAddressLabel = new ValueLabel<Uzer>() {
        public String toLabel(Uzer value, int index) {
            return value.getRealname() + "(" + value.getEmail() + ")";
        }
    };

    public static final ValueLabel<ContractAttachment> attachmentLabel = new ValueLabel<ContractAttachment>() {
        public String toLabel(ContractAttachment value, int index) {
            return value.getFileName();
        }
    };

    public static final ValueLabel<EMailAddress> emailAddressLabel = new ValueLabel<EMailAddress>() {
        public String toLabel(EMailAddress value, int index) {
            return value.getRealname() + "(" + value.getEmail() + ")";
        }
    };

    public static final ValueLabel<Material> materialLabel = new ValueLabel<Material>() {
        public String toLabel(Material value, int index) {
            return value.getCode();
        }
    };
}
